% load('training_output_norm')
% load('training_input_rednoise_ortho_norm')
total_num=10000;
sizex=54;
sizey=98;
Multi=1;
layers = [
    imageInputLayer([sizex sizey Multi])
    
    convolution2dLayer(53,2,'Padding','same')
    batchNormalizationLayer
    reluLayer
    
    averagePooling2dLayer(2,'Stride',2)
    
    convolution2dLayer(27,5,'Padding','same')
    batchNormalizationLayer
    reluLayer
    
    averagePooling2dLayer(2,'Stride',2)
    
    convolution2dLayer(13,10,'Padding','same')
    batchNormalizationLayer
    reluLayer
    averagePooling2dLayer(2,'Stride',2)
    convolution2dLayer(7,20,'Padding','same')
    batchNormalizationLayer
    reluLayer
    
    convolution2dLayer(3,50,'Padding','same')
    batchNormalizationLayer
    reluLayer
    
    averagePooling2dLayer(2,'Stride',2)
    convolution2dLayer(7,20,'Padding','same')
    batchNormalizationLayer
    reluLayer
    
    convolution2dLayer(13,10,'Padding','same')
    batchNormalizationLayer
    reluLayer
    averagePooling2dLayer(2,'Stride',2)
    
    
    convolution2dLayer(27,5,'Padding','same')
    batchNormalizationLayer
    reluLayer
    
    convolution2dLayer(53,2,'Padding','same')
    batchNormalizationLayer
    reluLayer
    
    
    dropoutLayer(0.2)
    fullyConnectedLayer(sizex*sizey*Multi)
    
    regressionLayer];

% epoch=[10 100 300 500];
% for i=1:4
%
%     options = trainingOptions('sgdm', ...
%     'MaxEpochs',epoch(i), ...
%     'InitialLearnRate',1e-3, ...
%     'LearnRateSchedule','piecewise', ...
%     'LearnRateDropFactor',0.1, ...
%     'LearnRateDropPeriod',75, ...
%     'Shuffle','every-epoch', ...
%     'Plots','training-progress', ...
%     'Verbose',true);
%     netEPOCH{i} = trainNetwork(image_input,output',layers,options);
% end

options = trainingOptions('sgdm', ...
    'MaxEpochs',600, ...
    'InitialLearnRate',1e-3, ...
    'LearnRateSchedule','piecewise', ...
    'LearnRateDropFactor',0.1, ...
    'LearnRateDropPeriod',75, ...
    'Shuffle','every-epoch', ...
    'Plots','training-progress', ...
    'Verbose',true);
%       'MiniBatchSize' ,32,...


net_fft = trainNetwork(image_input,output',layers,options);